﻿using System.Data.SqlClient;

namespace Northwind
{
    class AddProduct
    {
        public static int AddSingleProduct(string productName,int discontinued)
        {
            string sqlServerString = @"Server=.\SQLEXPRESS;Database=Northwind;Integrated Security=true";
            using (SqlConnection connection = new SqlConnection(sqlServerString))
            {
                connection.Open();
                string sqlQuery = @"INSERT INTO Products(ProductName,Discontinued) VALUES(@productName,@discontinued)";
                SqlCommand command = new SqlCommand(sqlQuery, connection);
                command.Parameters.Add("@productName", productName);
                command.Parameters.Add("@discontinued", discontinued);
                int affectedRows = command.ExecuteNonQuery();
                return affectedRows;
            }
        }
    }
}
